home *** CD-ROM | disk | FTP | other *** search
/ SGI Support Advantage Support Libraries 1995 March / SGI Support Advantage Support Libraries 1995 Mar.iso / CDrelnotes < prev    next >
Text File  |  1995-03-08  |  4KB  |  153 lines

  1. #! /bin/sh
  2. #Tag 0x00000600
  3.  
  4. # 'relnotes' - View on-line release notes; this version for online
  5. # (on CD-ROM) release notes
  6.  
  7. # Use the code from the dirname shell script to save space
  8. dirname()
  9. {
  10. ans=`/usr/bin/expr \
  11.         "${1:-.}/" : '\(/\)/*[^/]*//*$' `
  12. if [ -n "$ans" ];then
  13.         echo $ans
  14. else
  15.         ans=`/usr/bin/expr \
  16.                 "${1:-.}/" : '\(.*[^/]\)//*[^/][^/]*//*$' `
  17.         if [ -n "$ans" ];then
  18.                 echo $ans
  19.         else
  20.                 echo "."
  21.         fi
  22. fi
  23. exit 0
  24. }
  25.  
  26. SRCDIR=`dirname $0`/relnotes/
  27.  
  28. # if term not set, or no terminfo dirs, assume we are on the
  29. # textport in the miniroot
  30. if [ ! -n "$TERM" -o \( ! -d /usr/lib/terminfo -a ! -d "$TERMINFO" \) ]
  31. then
  32.     TERM=dumb LINES=40 COLUMNS=80
  33.     export TERM LINES COLUMNS
  34. fi
  35.  
  36. Usage="\n
  37.     'relnotes -h' -- print this message\n
  38.     'relnotes' -- list products that have on-line release notes \n
  39. \t\t\tcurrently installed\n
  40.     'relnotes <product>' -- show table of contents for a product's \n
  41. \t\t\ton-line release notes\n
  42.     'relnotes <product> <chapter> ... ' -- display specific chapters of \n
  43. \t\t\t\ta product's on-line release notes\n
  44.     'relnotes -t <product> <chapter> ... ' -- print specific chapters of \n
  45. \t\t\t\ta product's on-line release notes\n"
  46.  
  47. if [ "$1" = "-h" ] # give help and exit
  48. then
  49.     echo $Usage
  50.     exit
  51. fi
  52.  
  53. list_relnotes=/tmp/relnoteslist$$
  54. product=/tmp/relnotesproduct$$
  55. cleanup="rm -f $list_relnotes $product"
  56. trap "$cleanup" 1 2 3 15
  57.  
  58. # Create a list of products which have release notes installed.
  59. (cd $SRCDIR; find . -follow -type f -name TC -print | \
  60.     sed -e 's%./%%' -e "s%/TC%%" | xargs ls -trd1 ) > $list_relnotes
  61. if [ ! -s $list_relnotes ]
  62. then
  63.     echo "Sorry, but no products have release notes installed\n"
  64.     rm -f $list_relnotes
  65.     exit
  66. fi
  67.  
  68. if [ $# -eq 0 ]    # no args - show installed relnotes
  69. then
  70.     echo "The following products have release notes installed:\n"
  71.     cat $list_relnotes
  72.     echo "\nUse \"$0 productname\" to see the chapter list for a product"
  73.     $cleanup
  74.     exit
  75. fi
  76.  
  77. validproduct=no
  78. tflag=
  79. while [ $# -gt 0 ] # As long as we have arguments ....
  80. do
  81.     # Recognize old-style args, but don't support them.
  82.     if [ "$1" = "-p" ]
  83.     then
  84.       echo "The -p and -c options are no longer needed."
  85.       echo $Usage
  86.       $cleanup 
  87.       exit 1
  88.     fi
  89.  
  90.     # Support for printing chapters.
  91.     if [ "$1" = "-t" ]
  92.     then
  93.       tflag=$1
  94.       shift 
  95.       continue
  96.     fi
  97.     
  98.     # Invalid option?
  99.     case "$1" {
  100.     -*)
  101.       echo "$1 is an invalid option."
  102.       echo $Usage
  103.       $cleanup
  104.       exit 1
  105.       ;;
  106.     }
  107.  
  108.     if [ "$validproduct" = "no" ]
  109.     then
  110.       echo $1 > $product
  111.       match=`comm -12 $list_relnotes $product  | wc -l`
  112.       if [ $match -eq 1 ];
  113.       then
  114.          validproduct=$1    
  115.          shift
  116.          if [ $# -gt 0 ];
  117.          then
  118.             continue
  119.          fi
  120.          if [ -f $SRCDIR$validproduct/TC ];
  121.          then
  122.             echo "The chapters for the \"$validproduct\" product's release notes are:\n"
  123.             cat $SRCDIR$validproduct/TC 
  124.          else
  125.             echo "The \"$validproduct\" product's release notes are installed, "
  126.             echo "but its table of contents file is missing.\n"
  127.             echo "The chapters that are installed are:\n"
  128.             cd $SRCDIR${validproduct}; /bin/ls ch*.z | sed -e "/ch\(.*\)\.z/s//\1/"
  129.          fi
  130.          echo "\nUse \"$0 productname chapter\" to view a chapter"
  131.       else  # Not an installed product
  132.          echo "Sorry, but there are no installed release notes for the \"$1\" product.\n"
  133.          $cleanup ; exit 1
  134.       fi
  135.     else # Have a valid product.
  136.       cd $SRCDIR$validproduct
  137.       # Let 'man' report on chapters it can't find.
  138.       man $tflag -d ch${1}.z
  139.       shift
  140.       if [ $# -gt 0 ];
  141.       then
  142.         echo "Next chapter ('q' to quit):\c"
  143.         read ans
  144.         if [ "$ans" = "q" ];
  145.         then
  146.             $cleanup
  147.             exit
  148.         fi
  149.       fi
  150.     fi
  151. done
  152. $cleanup
  153.